package com.beagle.njddapp.ui.presenter;

import com.beagle.njddapp.base.ApiService;
import com.beagle.njddapp.base.BasePresenter;
import com.beagle.njddapp.base.OilApiService;
import com.beagle.njddapp.base.RetrofitHttp;
import com.beagle.njddapp.bean.oil.OilBean;
import com.beagle.njddapp.bean.oil.RateBean;
import com.beagle.njddapp.net.BaseOilHttpResponse;
import com.beagle.njddapp.net.HttpResponseObserver;
import com.beagle.njddapp.net.RxSchedulers;
import com.beagle.njddapp.ui.view.LoginView;
import com.beagle.njddapp.ui.view.UserCenterView;

import okhttp3.RequestBody;

/**
 * @author hxx
 * @date 2021-03-02 22:33
 */
public class UserCenterPresenter extends BasePresenter<UserCenterView> {
    private OilApiService apiService;

    public UserCenterPresenter() {
        retrofit2.Retrofit retrofit = RetrofitHttp.provideRetrofit();
        //获取接口对象
        apiService = retrofit.create(OilApiService.class);

    }
    public void getPj(){
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json;charset=UTF-8"),"{}");
        apiService.getTakerRate(body).compose(RxSchedulers.compose()).safeSubscribe(new HttpResponseObserver<BaseOilHttpResponse<RateBean>>() {
            @Override
            public void success(BaseOilHttpResponse<RateBean> oilHttpResponse) {
                if (oilHttpResponse.result!=null){
                    getView().showRate(oilHttpResponse.result);
                }
            }

            @Override
            public void error(int code, String message) {

            }
        });
    }

}
